﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WiiGeeDotNet.filter
{
  public class DirectionalEquivalenceFilter : Filter
  {

    private double m_sensivity;
    private double[] m_reference;

    public DirectionalEquivalenceFilter()
      : base()
    {
      this.Reset();
    }

    public new void Reset()
    {
      this.m_sensivity = 0.2;
      this.m_reference = new double[] { 0.0, 0.0, 0.0 };
    }

    public double Sensivity
    {
      get { return m_sensivity; }
      set { m_sensivity = value; }
    }

    public override double[] FilterAlgorithm(double[] vector)
    {
      if (vector[0] < m_reference[0] - this.m_sensivity ||
         vector[0] > m_reference[0] + this.m_sensivity ||
         vector[1] < m_reference[1] - this.m_sensivity ||
         vector[1] > m_reference[1] + this.m_sensivity ||
         vector[2] < m_reference[2] - this.m_sensivity ||
         vector[2] > m_reference[2] + this.m_sensivity)
      {
        this.m_reference = vector;
        return vector;
      }
      else
      {
        return null;
      }
    }
  }
}
